#pragma once

#include <iostream>
#include <string>
#include <pthread.h>
#include <unistd.h>

using func_t = void *(*)(void *);
class MyThread
{
private:
    std::string _name;
    pthread_t _tid;
    func_t _func;

public:
    MyThread(std::string name, pthread_t tid, func_t func)
        : _name(name), _tid(tid), _func(func)
    {
        std::cout << "创建" << _name << "成功" << std::endl;
    }
    bool Start()
    {
        int n = pthread_create(&_tid, nullptr, _func, (void *)_name.c_str());
        if (n != 0) return false;
        return true;
    }
    void Join()
    {
        pthread_join(_tid, nullptr);
    }
    ~MyThread()
    {
    }
};